package dawi.fcs.servicio.generico;

import java.util.HashMap;
import java.util.Map;

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.factory.CallFactory;
import com.twilio.sdk.resource.instance.Account;

public class CallService {
	private String numero;
	// Find your Account Sid and Token at twilio.com/user/account
	public static final String ACCOUNT_SID = "AC4d3cb5346932b6b5383ef40dc9dc749c";
	public static final String AUTH_TOKEN = "0b97156abb126e4edea385f50fa4ba28";

	public static final String ACCOUNT_SID_FUK = "AC9e0a996e7b4dc99c17eeb56dfbb30fb7";
	public static final String AUTH_TOKEN_FUK = "e11c6b63d02c4bde6b1e3bf0efc8f7c8";

	public static final String NRO_GARY = "51950201190";

	public static final String NRO_FUK = "51993532902";

	public CallService(String numero) throws TwilioRestException {
		this.numero = numero;
	}

	public void executeCall() throws TwilioRestException {
		TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID_FUK,
				AUTH_TOKEN_FUK);
		Account mainAccount = client.getAccount();
		CallFactory callFactory = mainAccount.getCallFactory();
		Map<String, String> callParams = new HashMap<String, String>();
		callParams.put("To", "51" + numero); // Replace with your phone number
		callParams.put("From", NRO_FUK); // Replace with a Twilio number
		callParams.put("Url", "http://twimlbin.com/6d164b72");
		// Make the call
		com.twilio.sdk.resource.instance.Call call = callFactory
				.create(callParams);

		// Print the call SID (a 32 digit hex like CA123..)
		System.out.println(call.getSid());
	}
}
